package com.itheima.Array.sort;

/**
 * @Author: Ethan Yankang
 * @Program: code-random-recordings
 * @Date: 2024-08-19 13:26
 **/
public class InsertSort {

    public static void insertSort(int[]  nums) {
        int len= nums.length;
        for (int i = 1; i < len; i++) {
            int key= nums[i];
            int Index=i-1;
            while (Index>=0&&nums[Index]>key){
                nums[Index+1]=nums[Index];
                Index--;
            }
            nums[Index+1]=key;
        }
    }
}
